<div class="modal-body pageContent" >
  <div class="row">
        <div class="col-lg-12 col-lg-offset-2">
            <div class="upload" >
              <form action="/product/addProductParameter" enctype="multipart/form-data" method='post' id="form1">
                <div class="form-group">
                    <input type="hidden" name="pid" value="{{pid}}">
                    <label class="col-lg-12 control-label">附件</label>
                    <div class="col-lg-12">
                        <input type="file" name="parameterFile" />
                    </div>
                </div>
              </form>
            </div>
        </div>
    </div>
</div>
<div class="modal-footer pageFooter">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        <button  class="btn btn-primary"  type="button"  onclick="doUpload()" >保存</button>  
  </div>
<script type="text/javascript">
$(document).ready(function() {  

   $('.selectpicker').selectpicker();//初始化
});
  function doUpload(){
     var formData = new FormData($("#form1")[0]); 
                     console.log(formData);
                        $.ajax({  
                              url: '/product/addProductParameter' ,  
                              type: 'POST',  
                              data: formData,  
                              async: true,  
                              cache: false,  
                              contentType: false,  
                              processData: false,  
                              success: function (returndata) { 
                                if(returndata.length===9371){   //session超时返回的登录页面 避免接口返回的也是字符串不是json
                                    location.href="/severError";
                                }else{  //正常处理 
                                    if (JSON.parse(returndata).statusCode == '200') {
                                    $("#productTable1").bootstrapTable('refresh',{url:"/product/getParameter",silent:true,query:{
                                            type:1,
                                            level:2
                                        }});
                                        toastr.success(JSON.parse(returndata).message+'!');
                                        $('#productListAdds').modal('hide');
                                    }else{
                                        toastr.warning(JSON.parse(returndata).message+'!');
                                    }
                                }
                                
                              },  
                              error: function (returndata) {  
                                    $('#productListAdds').modal('hide');
                                    toastr.error(JSON.parse(returndata).message+'!');
                              }  
                             }); 
 
                      }

</script>

<!-- <div class="modal-body pageContent">
    <div class="row">
        <div class="col-lg-12 col-lg-offset-2">
            <form id="productForm" method="post" class="form-horizontal" action="/product/addparameter">
                <div class="form-group">
                    <label class="col-lg-12 control-label">参数名称</label>
                    <div class="col-lg-12">
                        <input type="text" class="form-control" class="name" name="name" value="{{name}}" />
                    </div>
                </div>
                
                 <div class="form-group">
                    <label class="col-lg-12 control-label">产品参数</label>
                    <div class="col-lg-12">
                           <textarea style="height: 300px;" type="text" class="form-control" class="parameter"  name="parameter" ></textarea>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="modal-footer pageFooter">
   <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
   <button  class="btn btn-primary" data-dismiss="modal"  type="submit">保存</button>
</div>
<script type="text/javascript">
$(document).ready(function() {  

 function doUpload(){
        var formData = new FormData($("#form1")[0]); 
        $.ajax({  
                url: '/product/addProductParameter' ,  
                type: 'POST',  
                data: formData,  
                async: true,  
                cache: false,  
                contentType: false,  
                processData: false,  
                success: function (returndata) {  
                    if (JSON.parse(returndata).statusCode == '200') {
                        $("#productTable1").bootstrapTable('refresh',{url:"/product/getParameter",silent:true,query:{
                            type:1,
                            level:2
                            }});
                        toastr.success(JSON.parse(returndata).message+'!');
                        $('#productListAdds').modal('hide');
                    }else{
                        toastr.warning(JSON.parse(returndata).message+'!');
                    }
                },  
                error: function (returndata) {  
                    $('#productListAdds').modal('hide');
                toastr.error(JSON.parse(returndata).message+'!');
                }  
        }); 
}

</script>
